/**
 * \file Main.cpp
 * \brief Main file to start executing the application.
 */

#include<stdio.h>
#include<stdlib.h>
#include<time.h>

#include<QApplication>

#include"MainWindow.h"
#include"MapDisplay.h"
#include"Map.h"
#include"UnitFM.h"
#include"UnitHM.h"
#include"UnitLM.h"
#include"UnitLR.h"
#include"UnitSR.h"
#include"UnitSelector.h"

/**
 * \fn int main(int argc, char *argv[])
 * \brief Main function.
 * \param argc Argument count.
 * \param argv Arguments. Unused.
 */
int main(int argc, char *argv[]){
	QApplication app(argc, argv);
	srand(time(0));
	
	MainWindow mw;
	Map *map = new Map();
	QList<Unit*> teamA;
	QList<Unit*> teamB;
	
	if( !UnitSelector::getTeams(teamA, teamB, map) ){
		printf("No teams selected. Exiting now.\n");
		return 1;
	}
	/*
	printf("Making teams...\n");
	for(int i = 0; i < 8; i++){
		teamA.push_back(new UnitHM(map, AGE_EMA, TEAM_A));
		teamB.push_back(new UnitHM(map, AGE_EMA, TEAM_B));
// 		if(i%2){
// 			teamA.push_back( new UnitSR(map, AGE_HMA, TEAM_A) );
// 			teamB.push_back( new UnitLM(map, AGE_HMA, TEAM_B) );
// 		}else{
// 			teamA.push_back( new UnitLR(map, AGE_HMA, TEAM_A) );
// 			teamB.push_back( new UnitFM(map, AGE_HMA, TEAM_B) );
// 		}
	}*/
	printf("Done. Adding teams to map.\n");
	map->setTeams(teamA, teamB);
	printf("Done. Creating Display.\n");
	MapDisplay *display = new MapDisplay(map);
	mw.setMapDisplay(display);
	mw.show();
	int ret = app.exec();
	delete map;
	return ret;
} 
